<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\AdminController;
use Illuminate\Support\Facades\DB;
use App\Model\{Admin,User,Config,Cash};

/**
 * @menu_cat 积分
 * @icon sunglasses
 * @sort 20
 */
class IntegralController extends AdminController{

	public function __invoke(){
		return $this->index(func_get_args());
	}

	/**
	 * @menu 用户积分流水
	 * @return [type] [description]
	 */
	public function log(){
		$list = DB::table('integral_log');
        $this->_search($list, $search);
        $total = $list->count();
        $this->_order($list, ['id'=>'desc']);
        
        $list = $list->paginate(20);
        $uids = get_array_keys($list->items(),'uid');
        $users = DB::table('userdata')->whereIn('id',$uids)->select('id','nickname')->get()->toArray();
        $users = arrays_set_key($users,'id');

        foreach($list as &$item){
        	$item->user = $users[$item->uid];
        }

        return view('Admin.Integral.log')->with([
            'list' => $list,
            '_search'=>$search,
        ]); 
	}
}